//****************************
//** CSoundHigh
//**
//** A wave mixing class
//**
//****************************

#pragma once

#define NUM_BUFFERS				4	// number of audio buffers used by waveOutWrite
#define MAX_SOUNDS				16	// number of different effects
#define MAX_LOOPS				16	// number of different music loops

#define TIMERS_PER_BUFFER_TIME	2	
#define OVERALL_SCALE_FACTOR	2	// what all samples get divided by when mixing

typedef struct tagSOUND
  {
  bool		bLoaded;
  int		nVolume;				// volume setting
  int		nPanning;				// panning from 0 (full left) to 255 (full right), default is 127
  DWORD		nSamples;				// total number of samples in this effect
  DWORD		iCurrentSample;			// index to current sample
  LPVOID	pWaveFile;				// pointer to the loaded wav file/resource's alloc'ed data - so we can free
  short*	pData;					// hardcoded to 16 bit samples, yay
  }
SOUND, *PSOUND;

typedef struct tagWAVEFILE
  {
  DWORD           cbSize;                // Size of file
  LPWAVEFORMATEX  pwfxInfo;              // Wave Header
  LPBYTE          pbData;                // Wave Bits
  }
WAVEFILE, *LPWAVEFILE;


enum SoundMode {
	smStereo, smMono
};

enum SampleSize {
	ss8bit, ss16bit
};

class CSoundHigh
{
private:
	LPVOID LoadWaveFile(LPWSTR szFileName, LPWAVEFILE pWaveFile);
	BOOL ParseWaveMemory(LPVOID lpChunkOfMemory, LPWAVEFORMATEX  *lplpWaveHeader, 
		LPBYTE *lplpWaveSamples, LPDWORD lpcbWaveSize);
public:
    CSoundHigh();
    ~CSoundHigh();

	int SoundInit();
	int SoundLoad(int iSoundNum, LPTSTR lpFile);
	int SoundPlay(int iSoundNum);
	int SoundLoadLoop(int iSoundLoopNum, LPTSTR lpFile);
	int SoundPlayLoop(int iSoundLoopNum);
	int SoundDisable();



/*
    BOOL Load(LPTSTR lpFile);
    void Play();
    void Stop();
    DWORD GetLength() { return dwBytesRead; };
    void SetRepeat(BOOL bVal) { bRepeat = bVal; };
    BOOL Repeating() { return bRepeat; };
*/
};

